package com.marry.serialobject;

import com.marry.serialobject.model.Person;
import com.marry.serialobject.util.SerializeUtil;
import redis.clients.jedis.Jedis;

/**
 * @author ml
 * @create 2018-04-03--9:23
 */
public class test {
    public static void main(String[] args) {
        Jedis jedis=new Jedis("localhost");
        jedis.set("mykey","malin");
        System.out.println(jedis.get("mykey"));

        //序列化
        Person person=new Person(100,"马林");
        jedis.set("person:100".getBytes(), SerializeUtil.serialize(person));

        person=new Person(200,"佳佳");
        jedis.set("person:200".getBytes(),SerializeUtil.serialize(person));

        //反序列化
        byte[] unserial100=jedis.get(("person:100").getBytes());
        System.out.println((Person)SerializeUtil.unserialize(unserial100));
    }
}
